package net.xo68.coordinator.core.rpc;

/**
 * 对象序列化接口
 * @author wuxie
 * @version 2020-9-29
 */
public interface ObjectSerialize {

    /**
     * 序列化
     * @param obj
     * @return
     * @throws ObjectSerializeException
     */
    <T> byte[] serialize(final T obj) throws ObjectSerializeException;

    /**
     * 反序列化
     * @param data
     * @param classOfT
     * @param <T>
     * @return
     * @throws ObjectSerializeException
     */
    <T> T deserialize(final byte[] data, final String classOfT) throws ObjectSerializeException;

    /**
     * 反序列化
     * @param data
     * @param clazz
     * @param <T>
     * @return
     * @throws ObjectSerializeException
     */
    <T> T deserialize(final byte[] data, final Class<T> clazz) throws ObjectSerializeException;
}
